public class AssignOperatorTest2 {
    public static void main(String[] args) {
        int a = 1;
        int b = 2;

        //交换a,b变量的值
        //最基本的操作：借助第3个变量
        int temp = a;//把a变量的值复制一份给temp
        a = b; //把b变量的值赋值给a
        b = temp;
        System.out.println("a = " + a);//a=2
        System.out.println("b = " + b);//b=1

        System.out.println("========================");
        //（了解）有缺陷，i+j可能发生溢出
        int i = 1;
        int j = 2;

        i = i + j;//i新的值 = i旧的值 + j旧的值
        j = i - j;//j新的值 = i新的值 - j旧的值 = i旧的值 + j旧的值 - j旧的值 = i旧的值
        i = i - j;//i再次新的值 = i新的值  - j新的值 = i旧的值 + j旧的值 - i旧的值 = j旧的值
        System.out.println("i = " + i);
        System.out.println("j = " + j);

    }
}
